package com.xuzong.uilts;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {

    @Bean
    public Queue publishSubscribeQueueA() {
        return new Queue("PublishSubscribeQueueA", true);
    }

    @Bean
    public Queue publishSubscribeQueueB() {
        return new Queue("PublishSubscribeQueueB", true);
    }

    @Bean
    public Queue publishSubscribeQueueC() {
        return new Queue("PublishSubscribeQueueC", true);
    }

    @Bean
    public FanoutExchange publishSubscribeExchange() {
        return new FanoutExchange("PublishSubscribeExchange");
    }

    @Bean
    public Binding bindingQueueAToExchange() {
        return BindingBuilder.bind(publishSubscribeQueueA()).to(publishSubscribeExchange());
    }

    @Bean
    public Binding bindingQueueBToExchange() {
        return BindingBuilder.bind(publishSubscribeQueueB()).to(publishSubscribeExchange());
    }

    @Bean
    public Binding bindingQueueCToExchange() {
        return BindingBuilder.bind(publishSubscribeQueueC()).to(publishSubscribeExchange());
    }
}